package miss.sheffield;

/**
 *
 * @author Kevin Doyle
 * @email kfrdoyle[at]gmail[dot]com
 */
import java.io.*;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;

public class SheffieldFileInitDataReader {

    private static final int MAX_WAYPOINTS = 50;
    private static final String FILE_TITLE = "waypoints.txt";
    private static final String DELIMITER_PATTERN = ",\\s*";
    private static Double[] missionData = new Double[MAX_WAYPOINTS];

    public SheffieldFileInitDataReader() {
        try {
            readMissionData();
        } catch (FileNotFoundException ex) {
            Logger.getLogger(SheffieldFileInitDataReader.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void readMissionData() throws FileNotFoundException {
        int index = 0;
        try (Scanner s = new Scanner(new BufferedReader(new FileReader(FILE_TITLE))).useDelimiter(DELIMITER_PATTERN)) {

            while (s.hasNext()) {
                missionData[index] = Double.parseDouble(s.next());
                index++;

            }
        }
    }

    /**
     *
     * @return Array of initialization data
     */
    public Double[] getMissionData() {
        return missionData;
    }
}
